<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
class ArtController extends Controller
{
    /**
     * [文章详情页]
     * @param  Request $req    [request对象]
     * @param  [int]  $art_id  [文章id]
     * @return [page]          [返回文章页面]
     */
    public function art(Request $req,$art_id)
    {   
        //查出文章表的内容
        $artlist=DB::table('arts')->select('art_title','cat_id','art_img','art_author','art_click','art_pubtime')->where('art_status',1)->first();
        //查出文章详情表中的文章内容
        $extslist=DB::table('art_exts')->select('art_content')->where('art_id',$art_id)->first();
        $parentid=DB::table('cats')->select('parentid')->where('cat_id',$artlist->cat_id)->first();
        $catlist=DB::table('cats')->select('cat_id','cat_name')->where('parentid',$parentid->parentid)->get();
        return view('home.art',['art'=>$artlist,'exts'=>$extslist,'catlist'=>$catlist]);
    }
}
